%%{init: {'themeVariables': { 'fontSize': '12px'}}}%%
graph TD
    classDef path fill:#eee,stroke:#000,color:#000
    classDef plan fill:#fff,stroke-width:1px,color:#000
    classDef itemplan fill:#fff,stroke-width:2px,color:#000
    classDef unbatchedplan fill:#dff,stroke-width:1px,color:#000
    classDef sideeffectplan fill:#fcc,stroke-width:2px,color:#000
    classDef bucket fill:#f6f6f6,color:#000,stroke-width:2px,text-align:left

    subgraph "Buckets for queries/conditions/condition-featured-messages-minimal"
    Bucket0("Bucket 0 (root)<br /><br />1: <br />ᐳ: 9, 10, 46, 47, 48, 49, 11, 13, 18, 26, 30<br />2: 38, 42<br />3: PgSelect[8]<br />ᐳ: Access[39], Access[43]<br />4: PgSelectRows[14]"):::bucket
    Bucket1("Bucket 1 (listItem)<br />Deps: 48, 39, 43<br /><br />ROOT __Item{1}ᐸ14ᐳ[15]"):::bucket
    Bucket2("Bucket 2 (nullableBoundary)<br />Deps: 48, 39, 15, 43, 16<br /><br />ROOT PgSelectSingle{1}ᐸforumsᐳ[16]<br />1: <br />ᐳ: 40, 44, 41, 45<br />2: Connection[25]"):::bucket
    Bucket3("Bucket 3 (nullableBoundary)<br />Deps: 25, 45<br /><br />ROOT Connection{2}ᐸ41ᐳ[25]"):::bucket
    end
    Bucket0 --> Bucket1
    Bucket1 --> Bucket2
    Bucket2 --> Bucket3

    %% plan dependencies
    PgSelect8[["PgSelect[8∈0] ➊<br />ᐸforumsᐳ"]]:::plan
    Object11{{"Object[11∈0] ➊<br />ᐸ{pgSettings,withPgClient}ᐳ"}}:::plan
    Lambda13{{"Lambda[13∈0] ➊<br />ᐸincludeArchivedConditionᐳ<br />More deps:<br />- Constantᐸ[ undefined, 'INHERIT' ]ᐳ[46]"}}:::plan
    PgSelectInlineApply38["PgSelectInlineApply[38∈0] ➊<br />More deps:<br />- Constantᐸ5ᐳ[48]"]:::plan
    PgSelectInlineApply42["PgSelectInlineApply[42∈0] ➊"]:::plan
    Object11 & Lambda13 & PgSelectInlineApply38 & PgSelectInlineApply42 --> PgSelect8
    ApplyInput26{{"ApplyInput[26∈0] ➊"}}:::plan
    Lambda30{{"Lambda[30∈0] ➊<br />ᐸincludeArchivedConditionᐳ<br />More deps:<br />- Constantᐸ[HIDDEN]ᐳ[47]"}}:::plan
    ApplyInput26 & Lambda30 --> PgSelectInlineApply38
    Access9{{"Access[9∈0] ➊<br />ᐸ2.pgSettingsᐳ"}}:::plan
    Access10{{"Access[10∈0] ➊<br />ᐸ2.withPgClientᐳ"}}:::plan
    Access9 & Access10 --> Object11
    ApplyInput26 & Lambda30 --> PgSelectInlineApply42
    __Value2["__Value[2∈0] ➊<br />ᐸcontextᐳ"]:::plan
    __Value2 --> Access9
    __Value2 --> Access10
    PgSelectRows14[["PgSelectRows[14∈0] ➊"]]:::plan
    PgSelect8 --> PgSelectRows14
    __InputObject18{{"__InputObject[18∈0] ➊<br />More deps:<br />- Constantᐸtrueᐳ[49]"}}:::plan
    __InputObject18 --> ApplyInput26
    Access39{{"Access[39∈0] ➊<br />ᐸ8.m.subqueryDetailsFor21ᐳ"}}:::plan
    PgSelect8 --> Access39
    Access43{{"Access[43∈0] ➊<br />ᐸ8.m.subqueryDetailsFor32ᐳ"}}:::plan
    PgSelect8 --> Access43
    __Item15[/"__Item[15∈1]<br />ᐸ14ᐳ"\]:::itemplan
    PgSelectRows14 ==> __Item15
    PgSelectSingle16{{"PgSelectSingle[16∈1]<br />ᐸforumsᐳ"}}:::plan
    __Item15 --> PgSelectSingle16
    Connection25[["Connection[25∈2]<br />ᐸ41ᐳ<br />More deps:<br />- Constantᐸ5ᐳ[48]"]]:::plan
    Lambda41{{"Lambda[41∈2]<br />ᐸpgInlineViaSubqueryTransformᐳ"}}:::plan
    Lambda41 --> Connection25
    List40{{"List[40∈2]<br />ᐸ39,15ᐳ"}}:::plan
    Access39 & __Item15 --> List40
    List44{{"List[44∈2]<br />ᐸ43,15ᐳ"}}:::plan
    Access43 & __Item15 --> List44
    List40 --> Lambda41
    Lambda45{{"Lambda[45∈2]<br />ᐸpgInlineViaSubqueryTransformᐳ"}}:::plan
    List44 --> Lambda45
    PageInfo31{{"PageInfo[31∈3]"}}:::plan
    Connection25 --> PageInfo31
    First33{{"First[33∈3]"}}:::plan
    PgSelectRows34[["PgSelectRows[34∈3]"]]:::plan
    PgSelectRows34 --> First33
    Lambda45 --> PgSelectRows34
    PgSelectSingle35{{"PgSelectSingle[35∈3]<br />ᐸmessagesᐳ"}}:::plan
    First33 --> PgSelectSingle35
    PgClassExpression36{{"PgClassExpression[36∈3]<br />ᐸcount(*)ᐳ"}}:::plan
    PgSelectSingle35 --> PgClassExpression36
    Access37{{"Access[37∈3]<br />ᐸ25.hasNextPageᐳ"}}:::plan
    PageInfo31 o--o Access37

    %% define steps
    classDef bucket0 stroke:#696969
    class Bucket0,__Value2,PgSelect8,Access9,Access10,Object11,Lambda13,PgSelectRows14,__InputObject18,ApplyInput26,Lambda30,PgSelectInlineApply38,Access39,PgSelectInlineApply42,Access43 bucket0
    classDef bucket1 stroke:#00bfff
    class Bucket1,__Item15,PgSelectSingle16 bucket1
    classDef bucket2 stroke:#7f007f
    class Bucket2,Connection25,List40,Lambda41,List44,Lambda45 bucket2
    classDef bucket3 stroke:#ffa500
    class Bucket3,PageInfo31,First33,PgSelectRows34,PgSelectSingle35,PgClassExpression36,Access37 bucket3

